$(function(){
	$.ajax({
		url: urlcore + "/api/insuranceSetting/insuranceSettingDetails",
		type: "get",
		dataType: 'json',
		contentType: "application/json;charset=utf-8",
		success:function(data){
			if (data.success == true) {
				var da = data.data;
				if(da!=null){
				$('#thisId').val(da[0].id);
				$("#money").val(da[0].money);
				$("#time").val(da[0].time);
				}
			} else if (data.code == 'OVERTIME'){
				var thisUrl = window.location.href;
				if (thisUrl.indexOf('login.html') <= -1) {
					top.window.location.href="login.html";
				}

			} else {
				if (data.msg != '空数据') {
					alert(data.msg)
				}else{
					$('#thiscount').text(0);
				}
			}

		},
		error:function() {
			alert("error");
		}
	});
});

/**
 * 去修改
 */
function toModify(){
	$("#money").removeAttr("readonly");
	$("#time").removeAttr("readonly");
	$("#modifyRate").css("display","none");
	$("#submitRate").css("display","block");
	alert("开启设置！");
}

/**
 * 修改
 */
function subModify() {
	var id = $('#thisId').val();
	var money = $('#money').val();
	var time = $('#time').val();
	$.ajax({
		url: urlcore + "/api/insuranceSetting/addOrUpdateInsuranceSetting",
		type: "post",
		data: JSON.stringify({
	        "id": id,
	        "money": money,
	        "time": time,
	    }),
		dataType: 'json',
		contentType: "application/json;charset=utf-8",
		async: false,
		success:function(data){
			if (data.success == true) {
				$('#thisId').val(data.data.id);
				location.reload();
			} else if (data.code == 'OVERTIME'){
				var thisUrl = window.location.href;
				if (thisUrl.indexOf('login.html') <= -1) {
					top.window.location.href="login.html";
				}

			} else {
				if (data.msg != '空数据') {
					alert(data.msg)
				}
			}

		},
		error:function() {
			alert("error");
		}
	});
}

